package com.zhongyouyun.admin.controller;


import cn.hutool.core.lang.tree.Tree;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhongyouyun.admin.model.UserModel;
import com.zhongyouyun.admin.pojo.UserPojo;
import com.zhongyouyun.admin.pojo.UserRolePojo;
import com.zhongyouyun.other.annotation.SysLogAnnotation;
import com.zhongyouyun.other.model.PageRequest;
import com.zhongyouyun.utils.QueryUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.zhongyouyun.admin.service.UserRoleService;

import java.util.LinkedHashMap;
import java.util.List;


/**
 * @Author: shenyi
 * @Date: 2021-09-23
 * @Description: 用户角色中间表
 */
@RestController
@RequestMapping("/admin/z_user_role")
@Api(value = "用户角色controller", tags = {"用户角色接口"})
public class UserRoleController {
    @Autowired
    private UserRoleService service;


    @PostMapping("/findPage")
    @ResponseBody
    @ApiOperation(value = "获取角色下的用户", notes = "通过角色获取用户列表", produces = "r_id")
    @SysLogAnnotation(operModul = "系统管理>>用户角色", operType = "获取角色下的用户", operDesc = "通过角色获取用户列表")
    public IPage<UserRolePojo> findPage(@RequestBody @ApiParam(required = true, name = "分页查询器", value = "id:角色ID") PageRequest pageRequest) {
        QueryWrapper queryWrapper = new QueryWrapper<>();
        QueryUtils.fiterQuery(queryWrapper, pageRequest);
        Page page = new Page(pageRequest.getPageNum(), pageRequest.getPageSize());
        return service.selectPojoPage(page, queryWrapper);
    }


}
